<div class="row">
    <div class="col-sm-20">
        <h1 class="pagetitle" translate lib="web">credential</h1>
    </div>
</div>
<style type="text/css">
    .list-group-item:hover {
        color: #337ab7;
        text-shadow: 0 0 1em #337ab7;
        cursor: pointer;
    }

    .listgroupitemselected {
        border: 6px;
        border-color: black;
        background-color: #337ab7;
        color: white;
        cursor: pointer;
    }

    textarea {
        border: 0 none white;
        overflow: hidden;
        padding: 0;
        outline: none;
        background-color: #D0D0D0;
    }
</style>

<div class="form-inline">
    <label for="add" class="col-sm-1 control-label" translate lib="web">add</label>
    <div class="col-sm-6 input-group">
        <input type="text" name="user" id="user" ng-model="ctrl.searchtext" ng-keyup="ctrl.setkey($event)"
            class="form-control" ng-model-options="{ debounce: 500 }" ng-change="ctrl.handlefilter()"
            ng-keypress="ctrl.restrictInput($event)" autocomplete="off" />
        <button ng-click="ctrl.adduser()" type="button"
            ng-disabled="ctrl.loading==true || ctrl.searchSelectedItem==null" class="btn btn-success " translate
            lib="web">add</button>
    </div>
</div>
<div>
    <div class="col-sm-2"></div>
    <div class="col-sm-6">
        <ul class="list-group">
            <li class="list-group-item" ng-repeat="item in ctrl.searchFilteredList"
                ng-click="ctrl.fillTextbox(item.name)"
                ng-class="{listgroupitemselected: ctrl.searchSelectedItem._id==item._id}">
                ({{item._type}}) {{item.name}} <span ng-show="item.name != item.username">{{" " + item.username}}</span>
            </li>
        </ul>
    </div>
</div>


<section ng-repeat="ace in ctrl.model._acl" ng-show="ctrl.collection!='files'">
    <div class="form-inline">
        <label class="col-sm-4 control-label">{{ace.name}}: </label>

        <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 2)"
            ng-click="ctrl.toogleBit(ace, 2)" value="2" id="{{ace._id}}" /> read

        <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 3)"
            ng-click="ctrl.toogleBit(ace, 3)" value="3" id="{{ace._id}}" /> update

        <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 4)"
            ng-click="ctrl.toogleBit(ace, 4)" value="4" id="{{ace._id}}" /> delete

        <button type="button" ng-click="ctrl.removeuser(ace._id)" ng-disabled="ctrl.loading" translate
            lib="web">delete</button>
    </div>
</section>
<section ng-repeat="ace in ctrl.model.metadata._acl" ng-show="ctrl.collection=='files'">
    <div class="form-group">
        <div class="col-sm-9 input-group">
            <label class="col-sm-3 control-label">{{ace.name}}: </label>
            <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 1)"
                ng-click="ctrl.toogleBit(ace, 1)" value="1" id="{{ace._id}}" /> create
            <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 2)"
                ng-click="ctrl.toogleBit(ace, 2)" value="2" id="{{ace._id}}" /> read
            <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 3)"
                ng-click="ctrl.toogleBit(ace, 3)" value="3" id="{{ace._id}}" /> update
            <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 4)"
                ng-click="ctrl.toogleBit(ace, 4)" value="4" id="{{ace._id}}" /> delete
            <input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace, 5)"
                ng-click="ctrl.toogleBit(ace, 5)" value="5" id="{{ace._id}}" /> invoke
            <button type="button" ng-click="ctrl.removeuser(ace._id)" ng-disabled="ctrl.loading" translate
                lib="web">delete</button>
        </div>
    </div>
</section>

<pre ng-show="ErrorMessage!=null">{{ ErrorMessage }}</pre>
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
<form ng-submit="ctrl.submit()" class="form-horizontal" role="form" autocomplete="off">

    <div class="form-group">
        <label for="name" class="col-sm-2 control-label" translate lib="web">name</label>
        <div class="col-sm-6">
            <input ng-model="ctrl.model.name" class="form-control input-md" ng-disabled="ctrl.loading==true" />
        </div>
    </div>
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label" translate lib="web">username</label>
        <div class="col-sm-6">
            <input ng-model="ctrl.model.username" class="form-control input-md" ng-disabled="ctrl.loading==true"
                autocomplete="new-username" />
        </div>
    </div>
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label" translate lib="web">password</label>
        <div class="col-sm-6">
            <input ng-model="ctrl.model.password" type="text" class="form-control input-md"
                style="-webkit-text-security: disc;" ng-disabled="ctrl.loading==true" />
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" ng-disabled="ctrl.loading==true" class="btn btn-success" translate
                lib="web">save</button>
        </div>
    </div>


</form>